package tv.geir.slackspace.space;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import tv.geir.slackspace.common.SlackSpaceException;
import tv.geir.slackspace.space.ObjectSpace.Entry;

/**
 * @deprecated Not really, but don't use it until it's implemented!
 * @author Geir Gullestad Pettersen
 *
 */
public class LeaseExpireManager {

	private static Log log = LogFactory.getLog( LeaseExpireManager.class );
	
	private List<List<Entry>> generationList;
	
	private List<Entry> entryList;
	
	private long[] sleepTimes;
	
	private boolean[] cleaning;
	
	private boolean running;
	
	private ThreadGroup threadGroup; 
	
	private List<Thread> threads;
	
	public LeaseExpireManager( List<Entry> entryList, long... sleepTimes) {
		if( ArrayUtils.isEmpty( sleepTimes )) {
			throw new SlackSpaceException( "sleepTimes must have a value");
		}
		this.generationList = new Vector<List<Entry>>();
		this.sleepTimes = sleepTimes;
		this.cleaning = new boolean[ sleepTimes.length ];
		this.threadGroup = new ThreadGroup( "Lease managers" );
		this.threads = new ArrayList<Thread>();
		
		for( int i=0; i< sleepTimes.length; i++ ) {
			if( sleepTimes[i] == 0 ) {
				throw new SlackSpaceException( "sleep time cannot be 0" );
			}
			generationList.add( new Vector<Entry>() );
			cleaning[i] = false;
		}
	}
	
	

	private void startManager() {
		List<Entry> nextGeneration = null;
		for( int i = sleepTimes.length -1 ; i>= 0; i-- ) {
			final int generation = i;
			final long st = sleepTimes[i];
			final List<Entry> nextGen = nextGeneration;
			//LeaseExpireController controller = new LeaseExpireController()
			//Thread t = new Thread( threadGroup, "LeaseExpirationManager Generation[" +generation + "]" ) 
			
			// threads.add( t );
		}
	}
	
	
}
